package com.etoak.aspect;


import com.etoak.mapper.UserMapper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;

import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Aspect
public class VisitAspect {
    @Autowired
    UserMapper userMapper;
    @Pointcut("execution(* com.etoak.service..*.*(..))")
    public void etoak(){

    }
    @Before("etoak()")
    /**前置通知*/
    public void before(JoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        int id = (int) args[0];
        userMapper.updateVisit(id);

        String name = joinPoint.getSignature().getName();
        System.out.println(name + "方法执行了...");
    }
}